﻿/// <reference path="../core/jquery-1.4.2.min-vsdoc.js"/>
/// <reference path="../config/sw-config-default.js"/>
/// <reference path="../core/sw-prototype.js"/>
/// <reference path="../core/sw.js"/>
/// <reference path="../core/sw-control-core.js"/>

/***************************************************************************
jQuery rangeselector
NOTE: Created for SmartUI. 
Copyright 2010, Roy zhang
Features：
1.Number Range Selector
2.Date Range Selector
3.
4.
Update Note：

Needs：
****************************************************************************/

(function ($) {
    //    ///#region 设置
    //    var btnSetting = {
    //        css: 'btn'
    //        , csslink: 'lbtn'
    //    };
    //    ///#endregion

    $.fn.reditor = function (options) {
        /// <summary>pager</summary>
        /// <param name="options" type="Array">配置项</param>            
        options = $.extend({
            type: 'date'
            , css: 'txt txtrange'
        }, options);
        this.hide();
        var parent = this.parent(), id = this.attr('id'), field = this.attr('field');
        this.removeAttr('field');
        var txt = $(document.createElement('input')).addClass(options.css).attr('id', id + '_Begin').appendTo(parent);
        switch (options.type) {
            case 'date':
            case 'datetime':
                $icontrol.datepicker(txt);
                break;
            case 'num':
                txt.bind('blur keyup', function (e) { checkkey($(this)); });
                break;
        }
        $(document.createElement('span')).addClass('rangeto').text(' ').appendTo(parent);
        var txtEnd = txt.clone(true).attr('id', id + '_End').attr('field', field + '_End').appendTo(parent);
        txt.attr('field', field);
    };

    ///#region 公共方法
    function checkkey(txt) {
        txt.val(txt.val().replace(/[^0-9.]/g, ''));
    }
    ///#endregion

    ///#region 公共设置方法
    ///#endregion

})(jQuery);